import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_shop_z/model/commodity.dart';
import 'package:flutter_shop_z/config/service_url.dart';

//商品信息
class DetailsTopArea extends StatelessWidget {
  Commodity commodity;
  DetailsTopArea(this.commodity);
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        children: <Widget>[
          _commodityImage(),
          _commodityName(),
          _commodityPrice(),
        ],
      ),
    );
  }

  //商品图片
  Widget _commodityImage() {
    return Image.network(
      "${serviceUrl}goods/${commodity.categoryId}/${commodity.categorySubId}/${commodity.commodityImg}",
      width: ScreenUtil().setWidth(740),
    );
  }

//商品名称
  Widget _commodityName() {
    return Container(
      width: ScreenUtil().setWidth(730),
      padding: EdgeInsets.only(left: 15),
      child: Text(
        commodity.commodityName == null || commodity.commodityName.length < 0
            ? ''
            : commodity.commodityName,
        maxLines: 1,
        style: TextStyle(fontSize: ScreenUtil().setSp(30)),
      ),
    );
  }

//商品价格
  Widget _commodityPrice() {
    return Container(
      width: ScreenUtil().setWidth(730),
      padding: EdgeInsets.only(left: 15),
      margin: EdgeInsets.only(top: 8),
      child: Row(
        children: <Widget>[
          Text(
            "￥${commodity.commodityDiscountPrice}",
            style: TextStyle(
              color: Colors.purple,
              fontSize: ScreenUtil().setSp(40),
            ),
          ),
          Text(
            "市场价：￥${commodity.commodityOriginalPrice}",
            style: TextStyle(
              color: Colors.black26,
              decoration: TextDecoration.lineThrough,
            ),
          ),
        ],
      ),
    );
  }
}
